#ifndef COMM_H
#define COMM_H

#include <QTimer>
#include <ui_widget.h>
#include "deerrxhandle.h"
#include <QSerialPort>			//访问串口的库
#include <QSerialPortInfo>		//查询串口信息的库
#include <qobject.h>
//#include "includes.h"

typedef enum {
    Comm_Read = 0,
    Comm_Busy = 1,
    Comm_NotLink,
    Comm_OK,
}CommState_t;

class Comm : public QObject
{
    Q_OBJECT

public:
    explicit Comm(void);

public:
    int speed; //通信速率
    QString com;    //选择的COM口
    CommState_t State;
    void updata(QComboBox *list_uart);
    uint8_t Connect(QLabel *label_link, QPushButton *pushButton);
    uint8_t tx_uint16(uint8_t fun, uint16_t data);
    uint8_t tx_MotorCtrl(uint8_t Motor, uint8_t Mode, float data);
    uint8_t tx_data(uint8_t fun, uint8_t *data, uint8_t datalen);

private slots:
    void TimOutFun();
};

extern Comm uartComm;
#endif
